<script>
export default {
  name: 'DynSwitch',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: {
      type: [String, Number], // 验证类型后续可以增加
      default: ''
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handlerSwitch(value) {
      this.$emit('change', value)
      this.item.event && this.item.event(value)
    }
  },
  render: function(h) {
    return (
      <el-switch
        value={this.value}
        on-change={this.handlerSwitch.bind(this)}
        active-color={'#13ce66'}
        inactive-color={'#ff4949'}
        active-value={1}
        inactive-value={0}
        active-text={this.item.activeText}
        inactive-text={this.item.inactiveText}
      >
      </el-switch>
    )
  }
}
</script>

